//
//  LSLiveCompetitionNavView.m
//  LookScore
//
//  Created by wws on 2018/5/21.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSLiveCompetitionNavView.h"
#import "LSMarchDetailModel.h"
@implementation LSLiveCompetitionNavView{
    UIImageView * _leftImageView;
    UIImageView * _rightImageView;
    UILabel * _hostLabel;
    UILabel * _gurstLabel;
    UILabel * _middleLabel;
}

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self addContentView];
    }
    
    return self;
}

- (void)addContentView{
    
    _leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logoNull"]];
//    _leftImageView.backgroundColor = [UIColor redColor];
    [self addSubview:_leftImageView];
    _leftImageView.sd_layout
    .leftEqualToView(self)
    .centerYEqualToView(self)
    .widthIs(31)
    .heightIs(31);
    
    _rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logoNull"]];
//    _rightImageView.backgroundColor = [UIColor redColor];
    [self addSubview:_rightImageView];
    _rightImageView.sd_layout
    .rightEqualToView(self)
    .centerYEqualToView(self)
    .widthIs(31)
    .heightIs(31);
    
    _middleLabel = [[UILabel alloc] init];
    _middleLabel.textAlignment = NSTextAlignmentCenter;
    _middleLabel.textColor = LSTitleWhiteColor;
    _middleLabel.backgroundColor = RGBA(22,125,204,0.5);
    _middleLabel.font = LSFontSize14;
    [self addSubview:_middleLabel];
    
    _middleLabel.sd_layout
    .centerYEqualToView(self)
    .centerXEqualToView(self)
    .widthIs(42)
    .heightIs(22);
    
    _hostLabel = [[UILabel alloc] init];
    _hostLabel.textColor = LSTitleWhiteColor;
    _hostLabel.font = LSFontSize14;
    [self addSubview:_hostLabel];
    _hostLabel.sd_layout
    .centerYEqualToView(self)
    .rightSpaceToView(_middleLabel, 12)
    .autoHeightRatio(0);
    [_hostLabel setSingleLineAutoResizeWithMaxWidth:180];
    
    _gurstLabel = [[UILabel alloc] init];
    _gurstLabel.textColor = LSTitleWhiteColor;
    _gurstLabel.font = LSFontSize14;
    [self addSubview:_gurstLabel];
    _gurstLabel.sd_layout
    .centerYEqualToView(self)
    .leftSpaceToView(_middleLabel, 12)
    .autoHeightRatio(0);
    [_gurstLabel setSingleLineAutoResizeWithMaxWidth:180];
    
    
}
- (void)setModel:(LSMarchDetailModel *)model{
    _model = model;
    /**比赛状态：
     0 未开赛
     1 上半场
     3 下半场
     -1 结束
     */
    [_leftImageView sd_setImageWithURL:[NSURL URLWithString:TeamImageHeaderUrl(model.HomeTeamId)] placeholderImage:[UIImage imageNamed:@"logoNull"]];
    [_rightImageView sd_setImageWithURL:[NSURL URLWithString:TeamImageHeaderUrl(model.GuestTeamId)] placeholderImage:[UIImage imageNamed:@"logoNull"]];
   
    switch (model.MatchState) {
        case 0:{
            _middleLabel.text = @"未开";
        }
            break;
        case 1:{
            _middleLabel.text = @"";
            _hostLabel.text = model.HomeTeamScore;
            _gurstLabel.text = model.GuestTeamScore;
            
        }
            break;
        case 3:{
            _middleLabel.text = @"";
            _hostLabel.text = model.HomeTeamScore;
            _gurstLabel.text = model.GuestTeamScore;
        }
            break;
        case -1:{
            _middleLabel.text = @"结束";
            _hostLabel.text = model.HomeTeamScore;
            _gurstLabel.text = model.GuestTeamScore;
        }
            break;
        default:
            break;
    }
    
}
@end
